# CMake 最低版本号要求
cmake_minimum_required (VERSION 3.20)

if(POLICY CMP0042)
    cmake_policy(SET CMP0042 NEW)  # CMake 3.0+ (2.8.12): MacOS "@rpath" in target's install name
endif()

# 项目工程名
project (ch03)

# 下面两个用法的结果是相同的,set会修改SRC_LIST的值，aux_source_directory 会增加
set(SRC_Ex3_1_1 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_1_1.cpp)
set(SRC_Ex3_1_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_1_2.cpp)
set(SRC_Ex3_2_1 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_2_1.cpp)
set(SRC_Ex3_2_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_2_2.cpp)
set(SRC_Ex3_4_1 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_4_1.cpp)
set(SRC_Ex3_4_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise3_4_2.cpp)

#aux_source_directory(. SRC_LIST)


# 指定可执行文件存放目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)


# 构建可执行程序
ADD_EXECUTABLE(exercise3_1_1 ${SRC_Ex3_1_1})
ADD_EXECUTABLE(exercise3_1_2 ${SRC_Ex3_1_2})
ADD_EXECUTABLE(exercise3_2_1 ${SRC_Ex3_2_1})
ADD_EXECUTABLE(exercise3_2_2 ${SRC_Ex3_2_2})
ADD_EXECUTABLE(exercise3_4_1 ${SRC_Ex3_4_1})
ADD_EXECUTABLE(exercise3_4_2 ${SRC_Ex3_4_2})
#如何编译和使用
# mkdir -p D4Books/T1PrimerCpp/ch03/build
# cd D4Books/T1PrimerCpp/ch03/build
# cmake ..
# make or cmake --build .

#exercise3_1
# bin/exercise3_1

#the same as above ...